package 数组.easy;

/**
 * @author Lw中
 * @date 2020/9/13 9:48
 */
public class SiBaWu {

    /**
     * 最大连续1的个数
     * @param nums
     * @return
     */
    public static int findMaxConsecutiveOnes(int[] nums) {
        int low = 0, max = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                low++;
            } else {
                max = Math.max(max,low);
                low = 0;
            }
        }
        return Math.max(low, max);
    }

    public static void main(String[] args) {
        int[] arr = {1,1,0,1,1,1};
        int maxConsecutiveOnes = findMaxConsecutiveOnes(arr);
        System.out.println(maxConsecutiveOnes);
    }

}
